package handler

import (
	"360video/video-api/api/reponse"
	"360video/video-api/api/request"
	"360video/video-api/config"
	__ "360video/video-srv/handler/proto"
	"github.com/gin-gonic/gin"
	"log"
)

func HisToryAdd(c *gin.Context) {
	req := request.HisToryAdd{}
	if c.ShouldBind(&req) != nil {
		reponse.Error(c, "绑定失败")
		return
	}

	var r, err = config.VideosClient.HisToryAdd(c, &__.HisToryAddReq{
		UserId:    int64(req.UserId),
		VideoId:   int64(req.VideoId),
		EpisodeId: int64(req.EpisodeId),
		Progress:  int64(req.Progress),
	})
	if err != nil {
		log.Fatalf("could not greet: %v", err)
	}
	reponse.Success(c, "添加成功", __.HisToryAddResp{
		Id: r.Id,
	})
}
